<template>
  <NewsListPage
    :style="{
      width: '100%',
    }"
    :template="template"
    :recentNews="recentNews"
    :focusNews="focusNews"
  />
</template>

<script>
  import NewsListPage from './page/index';
  import { methods } from '@/utils';

  export default {
    name: 'Main',
    components: { NewsListPage },
    data() {
      return {
        recentNews: [],
        focusNews: [],
        template:
          methods.getUrlParam('template') === 'groupFocusNewsSection' ||
          methods.getUrlParam('template') === 'focusNewsSection'
            ? 'focus'
            : 'new',
      };
    },
    created() {
      const dataFile = methods.getUrlParam('dataFile');
      $.getJSON(dataFile, ({ rows }) => {
        if (rows) {
          this.focusNews = rows.filter((row) => row.focus);
          this.recentNews = rows;
        }
      });
    },
  };
</script>
